
--#include "data\functions\Boss\StoneTombPigCommon.lua" once


local npcId = 133
NpcDialog[npcId] = {}
local t = NpcDialog[npcId]

t.main = function(sysarg)
	local actorId = Actor.getActorId( sysarg )
	local killMon, addExp, lostMon, lostExp = StoneTomePigGetResult( actorId )		--进入副本才判断奖励提到点npc这里来
	--print("EnterStoneTombPig, killMon="..killMon..", addExp="..addExp..", lostMon="..lostMon..", lostExp="..lostExp)
	if addExp + lostExp > 0 then						--有残余奖励没有领取（此时按正式配置领奖）
		StoneTomePigOpenAward(sysarg)
		return
	end

	--print("t.main, npcId="..npcId)
	local circleLimit 	= StoneTombPigConfig.enterLevelLimit[1]
	local levelLimit 	= StoneTombPigConfig.enterLevelLimit[2]
	local maxTimes   	= GetActorDailyMaxTimes( sysarg, enDailyOpTimes_StoneTomb, 0 )
	local doneTimes  	= GetActorDailyDoneTimes( sysarg, enDailyOpTimes_StoneTomb, 0 )
	local lastTimes  	= maxTimes - doneTimes
	if lastTimes < 0 then
		lastTimes = 0
	end

	local strColor1 = Lang.ScriptTips.Color_Greed
	if not Actor.checkActorLevel( sysarg, levelLimit, circleLimit ) then
		strColor1 = Lang.ScriptTips.Color_Red
	end

	local strColor2 = Lang.ScriptTips.Color_Greed
	if lastTimes <= 0 then
		strColor2 = Lang.ScriptTips.Color_Red
	end

	local strCond1 = string.format( Lang.ScriptTips.LevelLimitCircleFormat, strColor1, circleLimit, levelLimit )
	local strCond2 = string.format( Lang.ScriptTips.LastTimesFormat, strColor2, lastTimes )
	local strCond  = strCond1.."\n"..strCond2

	-----------------
	local strDesc = Lang.ScriptTips.StoneTombPig003
	------------------
	local sweepBtn = "{btn;0;"..Lang.ScriptTips.ButtonSweep..";SweepStoneTombPigFromNpc;}"
	local okBtn 	= "{btn;0;"..Lang.ScriptTips.ButtonEnter..";EnterStoneTombPigFromNpc;}"			--{按钮;样式;按钮名;函数名;描述}
	local strBtnList = okBtn..sweepBtn
	
	--local localFun = string.format("OpenView,%s,%d", enLinkBuyItemWnd, cfg.itemId)
	--strBtnList = strBtnList .. string.format(cfg.buyBtn, localFun)

	-----------------
	local pack = DataPack.allocPacket(sysarg, LogicCmd.npcDialogSys.sysID, LogicCmd.npcDialogSys.sub.sNpcDlgData)
	
	DataPack.writeUint64(pack, Actor.getNpc(sysarg))
	DataPack.writeByte(pack, NpcDialogType.FYSDNpcDlg)
	DataPack.writeString(pack, strCond)
	DataPack.writeString(pack, strDesc)
	DataPack.writeString(pack, strBtnList)
	DataPack.writeChar(pack, -1)
	DataPack.writeByte(pack, 0);
	DataPack.flush(pack)

	return str
end

t.SweepStoneTombPigFromNpc = function(sysarg)
   SweepStoneTombPig(sysarg)
end
--进入活动场景
t.EnterStoneTombPigFromNpc = function ( sysarg )
	--print("EnterStoneTombPigFromNpc...")
	EnterStoneTombPig( sysarg, 0 )				--非体验进入，即正式进入副本
end
